#ifndef __CONTROLLED_OBJECT_H__
#define __CONTROLLED_OBJECT_H__

#pragma once

#include "RenderingConfig.h"

namespace Nezha
{
	class Controller;

	class GRAPHICS_ENTRY ControlledObject : public Refable
	{
	public:
		ControlledObject(const _string& name)
			:mName(name)
		{
		}

		ControlledObject(){}

		virtual ~ControlledObject(){}

		virtual void updateController(float dt);

		// update after rendering.
		virtual void postUpdateController(float dt);

		virtual void attachController(Controller* c);

		virtual void detachController();

		Controller* getController()
		{
			return mController;
		}

		const _string& getName() const
		{
			return mName;
		}

	protected:
		_string mName;
		Controller* mController;
	};

	typedef RefCountedPtr<ControlledObject>::Default ControlledObjectPtr;

	class GRAPHICS_ENTRY Controller
	{
	public:
		virtual ~Controller(){}

		virtual void update(float delta) = 0;

		virtual void postUpdate(float dt) = 0;

		virtual void attachTargetObject(ControlledObject* target);

		virtual void detachTarget();

		const _string& getName() const
		{
			return mName;
		}

	protected:
		Controller()
		{
		}

		_string mName;

		ControlledObjectPtr mTargetObject;
	};

}//end namespace Nezha

#endif //end __CONTROLLED_OBJECT_H__